package test.name.cyl.parseXml.y121120;

import java.io.FileInputStream;
import java.util.List;
import java.util.Map;

import junit.framework.Assert;

import name.cyl.parseXml.y121120.ParseXmlServices;

import org.junit.BeforeClass;
import org.junit.Test;

public class ParseXmlServicesTestCase {

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
    }

    @Test
    public void test() throws Exception {
        Map<String, List<Map<String, String>>> result = ParseXmlServices.parseXmlToMap(new FileInputStream(
                "src/name/cyl/parseXml/y121120/InputData.xml"));
        Assert.assertEquals(result.size(), 2);
        Assert.assertTrue(result.containsKey("User_Group"));
        Assert.assertTrue(result.containsKey("EditData"));
        
        List<Map<String, String>> list=result.get("User_Group");
        Assert.assertEquals(list.size(), 2);
        
        Map<String, String> record=list.get(0);
        Assert.assertEquals(record.size(), 3);
        Assert.assertEquals(record.get("UserName"), "translation-readonly");
        Assert.assertEquals(record.get("Password"), "password");
        Assert.assertEquals(record.get("Flag"), "1");
        
        record=list.get(1);
        Assert.assertEquals(record.size(), 3);
        Assert.assertEquals(record.get("UserName"), "translation-admin");
        Assert.assertEquals(record.get("Password"), "password");
        Assert.assertEquals(record.get("Flag"), "0");
        
        list=result.get("EditData");
        Assert.assertEquals(list.size(), 2);
        
        record=list.get(0);
        Assert.assertEquals(record.size(), 3);
        Assert.assertEquals(record.get("OldName"), "dep2");
        Assert.assertEquals(record.get("NewName"), "Store4");
        Assert.assertEquals(record.get("Flag"), "1");
        
        record=list.get(1);
        Assert.assertEquals(record.size(), 3);
        Assert.assertEquals(record.get("OldName"), "dep23");
        Assert.assertEquals(record.get("NewName"), "Store3");
        Assert.assertEquals(record.get("Flag"), "1");
    }

}
